﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace PerfAnalyzerUI
{
	class ColorManagement
	{
		/// <summary>
		/// List of available colors.
		/// </summary>
		private static List<Color> Colors = new List<Color>();
		
		/// <summary>
		/// Index of the current colors.
		/// </summary>
		private static int currentIndex = 0;

		/// <summary>
		/// Constructor.
		/// </summary>
		static ColorManagement()
		{
			var tmpColors = new List<Color>();

			tmpColors.Add(Color.Aqua);
			tmpColors.Add(Color.Aquamarine);
			tmpColors.Add(Color.Blue);
			tmpColors.Add(Color.BlueViolet);
			tmpColors.Add(Color.Brown);
			tmpColors.Add(Color.BurlyWood);
			tmpColors.Add(Color.Chartreuse);
			tmpColors.Add(Color.Coral);
			tmpColors.Add(Color.CornflowerBlue);
			tmpColors.Add(Color.Crimson);
			tmpColors.Add(Color.DarkBlue);
			tmpColors.Add(Color.DarkCyan);
			tmpColors.Add(Color.DarkGoldenrod);
			tmpColors.Add(Color.DarkGreen);
			tmpColors.Add(Color.DarkOrange);
			tmpColors.Add(Color.DarkOrchid);
			tmpColors.Add(Color.DarkSlateBlue);
			tmpColors.Add(Color.DeepPink);
			tmpColors.Add(Color.DeepSkyBlue);
			tmpColors.Add(Color.Green);
			tmpColors.Add(Color.Indigo);
			tmpColors.Add(Color.LimeGreen);
			tmpColors.Add(Color.OrangeRed);
			tmpColors.Add(Color.Red);
			tmpColors.Add(Color.RoyalBlue);

			var rand = new Random();

			// Randomly create a color order.
			while (tmpColors.Count > 0)
			{
				int c = rand.Next(tmpColors.Count);

				Colors.Add(tmpColors[c]);
				tmpColors.RemoveAt(c);
			}
		}

		/// <summary>
		/// Get next color.
		/// </summary>
		/// <returns>Next color.</returns>
		public static Color Next()
		{
			if (++currentIndex == Colors.Count)
			{
				currentIndex = 0;
			}

			return Colors[currentIndex];
		}

		/// <summary>
		/// Get current color.
		/// </summary>
		/// <returns>Current color.</returns>
		public static Color Current()
		{
			return Colors[currentIndex];
		}
	}
}
